package com.ak.demo.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class LoginDemo {



    @RequestMapping("/myLoginController")
    public String myLogin(){
        return "myLogin";
    }

    @RequestMapping("/toSuccess")
    public String toSuccess(){
        return "success";
    }

    @RequestMapping("/toFail")
    public String toFail(){
        return "fail";
    }

    @PreAuthorize("hasAuthority('vip1')")
    @RequestMapping("/Vip1")
    public String toVip1(){
        return "vip1";
    }
    @PreAuthorize("hasAuthority('vip2')")
    @RequestMapping("/Vip2")
    public String toVip2(){
        return "vip2";
    }

//    @Secured("ROLE_abc")
    @PreAuthorize("hasRole('abc')")
    @RequestMapping("/toRole")
    public String toRole(){
        return "Role";
    }
}
